package tech.dongliang.common.controller;

import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;
import tech.dongliang.common.enums.EBizError;
import tech.dongliang.common.exception.BizException;

public abstract class CommonController {
    public void vlidate(BindingResult result) {
        if (result.hasErrors()) {
            for (ObjectError error : result.getAllErrors()) {
                throw new BizException(EBizError.PARAMETER_VALIDATION_ERROR, error.getDefaultMessage());
            }
        }
    }
}
